home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Resources / Chat & Communication / Digsby build 37 / digsby_setup.exe / lib / gui / browser / iewindow.pyo (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2008-10-13  |  3.6 KB  |  99 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyo (Python 2.5)
  3.  
  4. from __future__ import with_statement
  5. import wx
  6. from random import randint
  7. import wx.lib.iewin as iewin
  8. from logging import getLogger
  9. log = getLogger('iewindow')
  10. from path import path
  11. from collections import defaultdict
  12. from util import traceguard, try_this, Delegate
  13. from time import time
  14. import stdpaths
  15.  
  16. class IEWindow(iewin.IEHtmlWindow):
  17.     
  18.     def __init__(self, parent, initialContents = '', url = None):
  19.         iewin.IEHtmlWindow.__init__(self, parent, style = wx.NO_BORDER)
  20.         self.OnNav = Delegate()
  21.         self.OnDoc = Delegate()
  22.         self._set_Silent(False)
  23.         if url is not None:
  24.             self.seturl = url
  25.             self.LoadUrl(url)
  26.         elif not initialContents:
  27.             pass
  28.         s = ''
  29.         if s:
  30.             self.SetPage(s)
  31.         
  32.  
  33.     
  34.     def LoadUrl(self, url):
  35.         if isinstance(url, unicode):
  36.             import warnings
  37.             warnings.warn('LoadUrl called with a unicode: %r' % url)
  38.             url = str(url)
  39.         
  40.         if not isinstance(url, str):
  41.             raise TypeError('must pass a string to LoadUrl')
  42.         
  43.         return iewin.IEHtmlWindow.LoadUrl(self, url)
  44.  
  45.     
  46.     def OnURL(self, url, callback):
  47.         if not callable(callback):
  48.             raise TypeError('callback must be callable')
  49.         
  50.         self.urltriggers[url] += [
  51.             callback]
  52.  
  53.     
  54.     def FileURL(self):
  55.         
  56.         try:
  57.             return 'file:///' + self.file.name.replace('\\', '/')
  58.         except AttributeError:
  59.             return self.seturl
  60.  
  61.  
  62.     FileURL = property(FileURL)
  63.     
  64.     def SetPage(self, content):
  65.         tempname = 'digsby-%s-%s.html' % (time(), randint(1, 9999))
  66.         p = stdpaths.temp / tempname
  67.         p.write_bytes(content)
  68.         return self.LoadUrl(p.url())
  69.  
  70.     
  71.     def NavigateComplete2(self, this, pDisp, URL):
  72.         self.OnNav(URL[0])
  73.  
  74.     
  75.     def DocumentComplete(self, this, pDisp, URL):
  76.         self.OnDoc(URL[0])
  77.  
  78.  
  79. if __name__ == '__main__':
  80.     a = wx.PySimpleApp()
  81.     
  82.     _ = lambda s: s
  83.     fbSize = (646, 436)
  84.     url = 'http://www.google.com/'
  85.     from util import trace
  86.     trace(IEWindow)
  87.     f = wx.Frame(None, size = fbSize, title = _('ie test'))
  88.     ie = IEWindow(f, url = url)
  89.     
  90.     def ondoc(e):
  91.         print type(e)
  92.         print e
  93.         print e.URL
  94.  
  95.     ie.Bind(iewin.EVT_DocumentComplete, ondoc)
  96.     f.Show()
  97.     a.MainLoop()
  98.  
  99.